/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Fenetre;

import Fenetre.BoutonListener.BouttonListenerRechercheBonDeCommande;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.BoxLayout;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author gerard.dl02
 */
public class FenetreRecherche extends JFrame{
    
    private JComboBox cSite;
    private JTextField cNumeroBox; /**/
    private JTextField cAnnes;
    private JTextField cSession;
    private JTextField cNumCommande;
    private JTextField cVille;
    private JTextField cMois;
    private JTextField cJours;
    private JTextField cIntervenant;
    private JTextField cNbSemaine;
    private JComboBox cSessionBox;
    
    
    public FenetreRecherche(){
        
         
        this.setSize(900, 900);
        this.setTitle("Recherche");
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        
        
        
        
        
        
     
        
        
        try {
        this.setContentPane(this.createPaneRecherche());
        } catch (Exception e){
            new FenetreException(e);
        }
        this.setVisible(true); // Rend la fenêtre visible
        
        
        
    }
    
    private JPanel NumeroBdc() throws Exception {
        
        try {
        this.cSite = new ComboBoxSites();
        } catch (Exception e){
            throw new Exception(e.getMessage());
        }
        this.cAnnes = new JTextField(4);
        this.cMois = new JTextField(2);
        this.cNumCommande = new JTextField(4);
        
        JPanel panelNumero = new JPanel();
        panelNumero.add(new JLabel("Numero : "));
        panelNumero.add(cSite);
        panelNumero.add(cAnnes);
        panelNumero.add(new JLabel("/"));
        panelNumero.add(cMois);
        panelNumero.add(new JLabel("/"));
        panelNumero.add(cNumCommande);
        
        return panelNumero;
    }
   
    private JPanel panelSessions() throws Exception {
        
        try {
        this.cSessionBox = new ComboBoxSessions();
        } catch (Exception e) {
            throw new Exception(e.getMessage());
        }
        JPanel panelSessions = new JPanel();
        panelSessions.add(new JLabel("Session : "));
        panelSessions.add(cSessionBox);
        
        return panelSessions;
    }
    
    
    
    private JPanel bouttonRecherche(){
        
        
        
        
        JButton BoutonRecherche = new JButton("Recherche");
        JPanel panelBouton = new JPanel();
        
        BoutonRecherche.addActionListener(new BouttonListenerRechercheBonDeCommande(this));
        
        panelBouton.add(BoutonRecherche);
        
        return panelBouton;
        
    }
    
    
    private JPanel nSemaine(){
        
        this.cNbSemaine = new JTextField(2);
        
        JLabel labelNumero = new JLabel("Numéro de semaine");
       
        JPanel paneNumero = new JPanel();

        paneNumero.setLayout(new FlowLayout());
        
        paneNumero.add(labelNumero);
        paneNumero.add(cNbSemaine);
        
        return paneNumero;
        
    }
    
    
    
    private JPanel intervenant(){
        
        this.cIntervenant = new JTextField(10);
    
        
        JPanel panelIntervenant = new JPanel();
        JLabel labelIntervenant = new JLabel("Intervenant");
        
        panelIntervenant.setLayout(new FlowLayout());
        
        panelIntervenant.add(labelIntervenant);
        panelIntervenant.add(cIntervenant);

        return panelIntervenant;
        
    }
    
    
    
    
    private JPanel labelRecherche(){
        
        JLabel recheche = new JLabel("Recherche par :");
        JPanel panelLabel = new JPanel();
        
        panelLabel.add(recheche);  
        
        return panelLabel;
        
    }
    
    private JPanel createPaneRecherche() throws Exception{
        
        JPanel createPane = new JPanel();
        BoxLayout bLayout1 = new BoxLayout(createPane,BoxLayout.PAGE_AXIS);
        createPane.setLayout(bLayout1);
        
        createPane.add(new JLabel("Recherche par : "));
        try {
        createPane.add(this.NumeroBdc());
        } catch (Exception e){
            throw new Exception(e.getMessage());
        }
        createPane.add(this.panelSessions());
        createPane.add(this.intervenant());
        createPane.add(this.nSemaine());
        
        JPanel panelFinale = new JPanel();
        BoxLayout bLayout2 = new BoxLayout(panelFinale,BoxLayout.PAGE_AXIS);
        panelFinale.setLayout(bLayout2);
        
        panelFinale.add(new MenuBar());
        panelFinale.add(createPane);
        panelFinale.add(this.bouttonRecherche());
 
        return panelFinale;
        
    }

    public JTextField getcNumeroBox() {
        return cNumeroBox;
    }

    public JTextField getcAnnes() {
        return cAnnes;
    }

    public JTextField getcSession() {
        return cSession;
    }

    public JTextField getcNumCommande() {
        return cNumCommande;
    }

    public JTextField getcVille() {
        return cVille;
    }

    public JTextField getcMois() {
        return cMois;
    }

    public JTextField getcJours() {
        return cJours;
    }

    public JTextField getcIntervenant() {
        return cIntervenant;
    }

    public JTextField getcNbSemaine() {
        return cNbSemaine;
    }

    public JComboBox getcSessionBox() {
        return cSessionBox;
    }
    
    
    
    
    
    
    
    
    
    
    
    
}
